<template>
        <el-container class="layout-container-demo" style="height: 700px">
            <el-aside width="200px">
                <el-scrollbar>
                    <el-menu  @select="show">
                        <el-sub-menu index="1" v-if="store.auth.role==0">
                            <template #title>
                                <el-icon><Avatar /></el-icon>管理页面
                            </template>
                            <el-menu-item-group>
                                <el-menu-item index="1-1" >数据上传</el-menu-item>
                            </el-menu-item-group>
                        </el-sub-menu>
                        <el-sub-menu index="2"  v-if="store.auth.role==0||store.auth.role==2">
                            <template #title>
                                <el-icon><DataBoard /></el-icon>中层干部
                            </template>
                            <el-menu-item index="2-1" v-if="store.auth.role==0">中层干部列表</el-menu-item>
                            <el-menu-item index="2-2" v-if="store.auth.role==0">领导班子列表</el-menu-item>
                            <el-menu-item index="2-3" v-if="store.auth.role==2">上传报告</el-menu-item>
                        </el-sub-menu>
                        <el-sub-menu index="3" v-if="store.auth.role==0">
                            <template #title>
                                <el-icon><DataBoard /></el-icon>数据统计
                            </template>
                            <el-menu-item index="3-1">考评情况</el-menu-item>
                            <el-menu-item index="3-2">数据导出</el-menu-item>
                        </el-sub-menu>
                        <el-sub-menu index="4" v-if="store.auth.role==1||store.auth.role==3">
                            <template #title>
                                <el-icon><DataBoard /></el-icon>投票
                            </template>
                            <el-menu-item index="4-1">中层干部投票列表</el-menu-item>
                            <el-menu-item index="4-2">领导班子投票列表</el-menu-item>
                        </el-sub-menu>
                    </el-menu>
                </el-scrollbar>
            </el-aside>

            <el-container>
                <el-header >
                    <div style="text-align: center;font-size: 20px">中层干部考评系统</div>
                    <div class="topRight" style="text-align: right; font-size: 12px">
                        用户名:<span>{{nickname}}</span> 姓名:<span>{{realname}}</span>
                        <el-button type="danger" plain @click="logout()">退出登录</el-button>
                    </div>
                </el-header>
                <el-main>
                    <div v-show="page==''">欢迎{{nickname}},进入我们的中层干部考评系统！</div>
                    <div v-show="page=='1-1'"><upload></upload></div>
                    <div v-show="page=='2-1'"><analyze></analyze></div>
                    <div v-show="page=='2-2'"><analyze1></analyze1></div>
                    <div v-show="page=='2-3'"><upload1></upload1></div>
                    <div v-show="page=='3-1'"><datas></datas></div>
                    <div v-show="page=='3-2'"><outport></outport></div>
                    <div v-show="page=='4-1'"><vote></vote></div>
                    <div v-show="page=='4-2'"><leadervote></leadervote></div>
                </el-main>
            </el-container>
        </el-container>
</template>
<script setup>
import { get } from '@/utils/request.js'
import {ElMessage} from 'element-plus'
import router from '@/router'
import { ref,onMounted } from 'vue'
import {userStore} from '@/stores/counter.js'
import { User, Message, Reading,Avatar,Folder,Monitor,DataBoard } from '@element-plus/icons-vue'
import upload from '@/views/UploadVue.vue'
import analyze from '@/views/AnalyzeVue.vue'
import analyze1 from '@/views/AnalyzeVue1.vue'
import vote from '@/views/VoteVue.vue'
import leadervote from '@/views/LeaderVoteVue.vue'
import upload1 from '@/views/UploadVue1.vue'
import datas from '@/views/DataVue.vue'
import outport from '@/views/OutportVue.vue'

const nickname = ref('')
const realname = ref('')
const page = ref('')
const store=userStore()


get('/user/getUser',(message)=>{
console.log(message)
nickname.value=message.nickname
realname.value=message.realname
store.auth.user=message.nickname
store.auth.realname=message.realname
store.auth.idd=message.id
store.auth.role=message.role
})

const logout=()=>{
get('/api/auth/logout',(message)=>{
router.push('/')
ElMessage.success(message)
store.auth.user=null
store.auth.realname=null
auth.auth.role=null
auth.auth.idd=null
})
}

const show=(index)=>{
page.value=index
}

</script>
<style scoped>
    .layout-container-demo .el-header {
  position: relative;
  background-color: var(--el-color-primary-light-7);
  color: var(--el-text-color-primary);
}
.layout-container-demo .el-aside {
  color: var(--el-text-color-primary);
  background: var(--el-color-primary-light-8);
}
.layout-container-demo .el-menu {
  border-right: none;
}
.layout-container-demo .el-main {
  padding: 0;
}
.layout-container-demo .toolbar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  right: 20px;
}
</style>